/*
 * Copyright 2009 Brian Mackay brianwmackay@msn.com
 *   All Rights Reserved. See end of file
 */
package com.bmackay.vonsteuben.client.files;

import com.bmackay.vonsteuben.base.conf.ConfigParserImpl;
import com.bmackay.vonsteuben.base.conf.PropertyConstants;
import com.bmackay.vonsteuben.client.base.maps.ApplicationGlobals;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.hadoop.filecache.DistributedCache;
import org.apache.hadoop.fs.Path;

public class FileLoader extends ApplicationGlobals {

    private String currentConfigName = "";

    public FileLoader(String configuration, String currentConfigName) {
        super(configuration);
        this.currentConfigName = currentConfigName;
    }

    public void set() {
        Path[] files = null;
        try {
            files = DistributedCache.getLocalCacheFiles(this);
        } catch (IOException ex) {
            Logger.getLogger(FileLoader.class.getName()).log(Level.SEVERE, null, ex);
        }
        for (int i = 0; i < files.length; i++) {
            String file = files[i].toString();

            if (file.contains(PropertyConstants.VS_CACHE)) {
                LocalCacheFiles.getInstance().put(files[i].getName(),
                        new ConfigParserImpl(file, false));
            }
        }
    }
}

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */